<h2>DESCRIPTION</h2>

<em>r.fillnulls</em> fills NULL pixels (no data areas) in input raster
map and stores filled data to a new output raster map. The fill areas
are interpolated from the no data area boundaries buffer
using <em><a href="v.surf.rst.html">v.surf.rst</a></em> regularized
spline interpolation with tension (<b>method=rst</b>) or
<em><a href="r.resamp.bspline.html">r.resamp.bspline</a></em> cubic or
linear spline interpolation with Tykhonov regularization.

<h2>NOTES</h2>

Each area boundary buffer is set to three times the map resolution to get nominally
three points around the edge. This way the algorithm interpolates into the hole with
a trained slope and curvature at the edges, in order to avoid that such a flat plane
is generated in a hole. The width of edge area can be adjusted by 
changing the edge parameter.
<p>During the interpolation following warning may occur when using the RST method:<p>
<tt>
Warning: strip exists with insufficient data<br>
Warning: taking too long to find points for interpolation--please change
the region to area where your points are</tt>
<p>
This warning is generated if large data holes exist within the surface.
As the idea of <em>r.fillnulls</em> is to fill such holes, the user may
ignore the warning. The interpolation will be continued. However, the user
may pay attention to below notes.
<p>
If interpolation fails, temporary raster and vector maps are left in place to allow
unfilled map hole (NULL area) identification and manual repair.

<p>
When using the default RST method, the algorithm is based
on <em><a href="v.surf.rst.html">v.surf.rst</a></em> regularized
splines with tension interpolation module which interpolates the
raster cell values for NULL data areas from the boundary values of the
NULL data area. An eventual raster MASK is respected during the NULL
data area(s) filling. The interpolated values are patched into the
NULL data area(s) of the input map and saved into a new raster map.

Otherwise, either the linear or cubic spline interpolation with
Tykhonov regularization can be selected (based on
<em><a href="r.resamp.bspline.html">r.resamp.bspline</a></em>). 

<h2>WARNING</h2>

Depending on the shape of the NULL data area(s) problems may occur due to an
insufficient number of input cell values for the interpolation process. Most
problems will occur if a NULL data area reaches a large amount of the map
boundary. The user will have to carefully check the result using
<em><a href="r.mapcalc.html">r.mapcalc</a></em> (generating a
difference map to the input map and applying the
&quot;differences&quot; color table
with <em><a href="r.colors.html">r.colors</a></em>) and/or to query
individual cell values.

<p>
RST method stores temporary maps on hard disk. It will require at least as much
free space as one extra input raster map takes.

<h2>EXAMPLE</h2>

In this example, the SRTM elevation map in the
North Carolina sample dataset location is filtered for outlier
elevation values; missing pixels are then re-interpolated to obtain
a complete elevation map:

<div class="code"><pre>
g.region raster=elev_srtm_30m -p
d.mon wx0
d.histogram elev_srtm_30m

# remove SRTM outliers, i.e. SRTM below 50m (esp. lakes), leading to no data areas
r.mapcalc "elev_srtm_30m_filt = if(elev_srtm_30m < 50.0, null(), elev_srtm_30m)"
d.histogram elev_srtm_30m_filt
d.rast elev_srtm_30m_filt

# using the default RST method to fill these holes in DEM
r.fillnulls input=elev_srtm_30m_filt output=elev_srtm_30m_rst tension=20

# using the bilinear method to fill these holes in DEM
r.fillnulls input=elev_srtm_30m_filt output=elev_srtm_30m_bilin method=bilinear

d.histogram elev_srtm_30m_rst
d.rast elev_srtm_30m_rst

d.erase
d.histogram elev_srtm_30m_bilin
d.rast elev_srtm_30m_bilin

r.mapcalc "diff_rst_bilin = elev_srtm_30m_rst - elev_srtm_30m_bilin"
r.colors diff_rst_bilin color=differences

r.univar -e diff_rst_bilin
d.erase
d.rast diff_rst_bilin
d.legend diff_rst_bilin
</pre></div>

<h2>REFERENCES</h2>
<ul>
<li> Mitas, L., Mitasova, H., 1999, Spatial Interpolation. In: P.Longley,
M.F. Goodchild, D.J. Maguire, D.W.Rhind (Eds.), Geographical Information
Systems: Principles, Techniques, Management and Applications, Wiley,
pp.481-492

<li>Mitasova H., Mitas L.,&nbsp; Brown W.M.,&nbsp; D.P. Gerdes, I.
Kosinovsky, Baker, T.1995, Modeling spatially and temporally distributed
phenomena: New methods and tools for GRASS GIS. <i>International Journal of
GIS</i>, 9 (4), special issue on Integrating GIS and Environmental modeling,
433-446.

<li><a href="http://www4.ncsu.edu/~hmitaso/gmslab/papers/lmg.rev1.ps">Mitasova H.
and Mitas L. 1993</a>: Interpolation by Regularized Spline with Tension: I.
Theory and Implementation, <i>Mathematical Geology</i> 25, 641-655.

<li><a href="http://www4.ncsu.edu/~hmitaso/gmslab/papers/hmg.rev1.ps">Mitasova H.
and Hofierka L. 1993</a>: Interpolation by Regularized Spline with Tension:
II. Application to Terrain Modeling and Surface Geometry Analysis,
<i>Mathematical Geology</i> 25, 657-667.
</ul>

<h2>SEE ALSO</h2>

<em>
<a href="r.fill.dir.html">r.fill.dir</a>, 
<a href="r.mapcalc.html">r.mapcalc</a>,
<a href="r.resamp.bspline.html">r.resamp.bspline</a>,
<a href="v.surf.bspline.html">v.surf.bspline</a>,
<a href="v.surf.rst.html">v.surf.rst</a>
</em>

<h2>AUTHORS</h2>
Markus Neteler, University of Hannover  and Fondazione Edmund Mach<br>
Improvement by Hamish Bowman, NZ

<!--
<p>
<i>Last changed: $Date$</i>
-->
